/**
 * Description:
 * Class Name:Sub
 * Date:2022/1/12 16:05
 *
 * @author LTisme
 * @version JAVA17
 */
package 疯狂Java讲义.第5章_面向对象_上.多态.第5_8.继承与组合;

class Base{
    public Base(){
        test();
    }
    public void test(){
        System.out.println("将被子类重写的方法");
    }
}
public class Sub extends Base{
    private String name;

    @Override
    public void test() {
        System.out.println("子类重写父类的方法，" + "其name字符串的长度" + name.length());
    }

    public static void main(String[] args) {
        // 下面的代码会引发空指针异常
        var s = new Sub();
    }
}
